From: Florian Müllner Date: Sat, 10 Mar 2012 00:33:31 +0000 (+0100) Subject: viewSelector: Clean up focusTrap in search results X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~6105 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=ea14d7414126c214a6c0257a244de21b6f8b232c;p=gnome-shell.git viewSelector: Clean up focusTrap in search results Rather than relying on implementation details of StWidget's keyboard navigation to "hide" the focusTrap from arrow key navigation, implement the desired behavior explicitly in a custom widget. https://bugzilla.gnome.org/show_bug.cgi?id=663901 --- diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js index ae9127dca..df86dc66f 100644 --- a/js/ui/viewSelector.js +++ b/js/ui/viewSelector.js @@ -21,6 +21,19 @@ const Wanda = imports.ui.wanda; const WorkspacesView = imports.ui.workspacesView; +const FocusTrap = new Lang.Class({ + Name: 'FocusTrap', + Extends: St.Widget, + + vfunc_navigate_focus: function(from, direction) { + if (direction == Gtk.DirectionType.TAB_FORWARD || + direction == Gtk.DirectionType.TAB_BACKWARD) + return this.parent(from, direction); + return false; + } +}); + + const ViewSelector = new Lang.Class({ Name: 'ViewSelector', @@ -94,17 +107,11 @@ const ViewSelector = new Lang.Class({ // Since the entry isn't inside the results container we install this // dummy widget as the last results container child so that we can - // include the entry in the keynav tab path... - this._focusTrap = new St.Bin({ can_focus: true }); + // include the entry in the keynav tab path + this._focusTrap = new FocusTrap({ can_focus: true }); this._focusTrap.connect('key-focus-in', Lang.bind(this, function() { this._entry.grab_key_focus(); })); - // ... but make it unfocusable using arrow keys keynav by making its - // bounding box always contain the possible focus source's bounding - // box since StWidget's keynav logic won't ever select it as a target - // in that case. - this._focusTrap.add_constraint(new Clutter.BindConstraint({ source: this._searchResults.actor, - coordinate: Clutter.BindCoordinate.ALL })); this._searchResults.actor.add_actor(this._focusTrap); global.focus_manager.add_group(this._searchResults.actor);